file_name = str(input("请输入要统计的数据文件名："))

try:
    f = open(file_name)
    
    try:
        all_date = f.readlines()
        
        s = 0
        
        for i in all_date:
            s += float(i)
        
        a = s / len(all_date)    
        
        print("该文件数据的平均值是%d" ,{round(a,2)})
    except FileNotFoundError:
        print("文件不存在!")
    
    finally:
       f.close()


except Exception as e:
    print("其他问题!", e)

# python 内部异常类 Exception 返回出错原因
# except Exception as e:
#     print("发生意外:",e)
